﻿@model InspectionModel
@using Nop.Web.Framework.Localization
@using Nop.Core.Domain.XJ
@using Nop.Services.Security

@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)

<script>
    $(document).ready(function () {
        bindBootstrapTabSelectEvent('category-edit');
    });
</script>

<style type="text/css">
    .pic {
        width: 200px;
        height: 200px;
        object-fit: cover;
    }
</style>

<div class="content">
    <div class="form-horizontal">
        <div class="row">
            <div class="col-md-12 clearfix">
                <div class="pull-left">
                    @Html.Action("Mode", "Setting", new { modeName = "category-advanced-mode" })
                </div>
            </div>
        </div>
        <div id="category-edit" class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @Html.RenderBootstrapTabHeader("tab-info", new LocalizedString("基本信息"), true)
            </ul>
            <div class="tab-content">
                @Html.RenderBootstrapTabContent("tab-info", @TabInfo(), true)
            </div>
        </div>
    </div>
</div>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "category-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

@*save selected tab name*@
<input type="hidden" id="selected-tab-name" name="selected-tab-name" value="@(Html.GetSelectedTabName())">

@helper TabInfo()
{
var permissionService = EngineContext.Current.Resolve<IPermissionService>();
var canManageInspectionPlansView = permissionService.Authorize(StandardPermissionProvider.ManageInspectionPlansView);
var canManageMaintenancesView = permissionService.Authorize(StandardPermissionProvider.ManageMaintenancesView);
var canManageMyMaintenances = permissionService.Authorize(StandardPermissionProvider.ManageMyMaintenances);
    <div class="content">
        <div class="form-horizontal">
            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.TypeName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.TypeName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.PNo)
                            </div>
                            <div class="col-md-9">
                                @if (canManageInspectionPlansView)
                                {
                                    <a target="_blank" href="@Url.Content("~/Admin/InspectionPlan/View/")@Model.InspectionPlanId">@Model.PNo</a>
                                }
                                else
                                {
                                    @Html.NopDisplayFor(model => model.PNo)
                                }
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.XNo)
                            </div>
                            <div class="col-md-9">
                                @if (Model.MaintenanceId>0 &&( canManageMaintenancesView||canManageMyMaintenances))
                                {
                                    <a target="_blank" href="@Url.Content("~/Admin/Maintenance/View/")@Model.MaintenanceId">@Model.XNo</a>
                                }
                                else
                                {
                                    @Html.NopDisplayFor(model => model.XNo)
                                }
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.Name)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.Name)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.AimName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.AimName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.Content)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.Content)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.TeamName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.TeamName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.CustomerName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.CustomerName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.CreatedOn)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.CreatedOn)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.Comment)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.Comment)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                <div class="label-wrapper"><label class="control-label" for="Pictures" title="">巡检图片</label></div>
                            </div>
                            <div class="col-md-9">
                                @foreach (var item in Model.Pictures)
                                {
                                    <img src="@item" class="pic" />
                                }
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}
